﻿using MediatR;
using T_settlement.API.Application.Command.PayMoneyCommand;
using T_settlement.Infrastructure.Interfacec;

namespace T_settlement.API.Application.CommandHandlers.PayMoneyCommandHandlers
{
    public class DelPayMoneyCommandHandlers:IRequestHandler<DelPayMoneyCommand,int>
    {
        private readonly IPayMoneyRepository payMoneyRepository;

        public DelPayMoneyCommandHandlers(IPayMoneyRepository payMoneyRepository)
        {
            this.payMoneyRepository = payMoneyRepository;
        }

        public async Task<int> Handle(DelPayMoneyCommand request, CancellationToken cancellationToken)
        {
            var list = await payMoneyRepository.GetModelAsync(request.PayMoneyId);
            list.IsDel = true;
            var res = await payMoneyRepository.UpdateAsync(list);
            return res;
        }
    }
}
